﻿using System;
using System.Configuration;

namespace Alex.Library.Log.Configuration
{
    /// <summary>
    /// 邮件凭证元素
    /// </summary>
    public sealed class MailCredentialElement : ConfigurationElement
    {
        /// <summary>
        /// 用户名
        /// </summary>
        [ConfigurationProperty("username", IsRequired = true)]
        public string UserName
        {
            get
            {
                return (string)this["username"];
            }
        }

        /// <summary>
        /// 密码
        /// </summary>
        [ConfigurationProperty("password", IsRequired = true)]
        public string Password
        {
            get
            {
                return (string)this["password"];
            }
        }

        /// <summary>
        /// 根据配置获取凭证对象
        /// </summary>
        /// <returns></returns>
        public MailCredential GetCredentialObject()
        {
            return new MailCredential(this.UserName, this.Password);
        }
    }
}
